﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.PA
{
    class Class1
    {

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            
            
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {
                ppa.SchemePeriodActing.InsurantStates.Add("意外身故");
                double s = ppa.Amount - ppa.GetDutyTotalValue("意外伤残保险金");

                da.Value = s;
                ppa.IsCurrentFinish = true;
            }
        }


        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("公共交通意外伤残"))
            {
                ppa.SchemePeriodActing.InsurantStates.Add("意外身故");
                double s = ppa.Amount - ppa.GetDutyTotalValue("意外伤残保险金");

                da.Value = s;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("意外伤残"))
            {
                string s = ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("残疾程度给付比例").ToString().Trim();

                double f = 0;

                if (s == string.Empty)
                {
                    f = 0;
                }
                else if (s == "一级")
                {
                    f = 1;
                }
                else if (s == "二级")
                {
                    f = 0.75;
                }
                else if (s == "三级")
                {
                    f = 0.5;
                }
                else if (s == "四级")
                {
                    f=0.3;
                }
                else if (s == "五级")
                {
                    f =0.2;
                }
                else if (s == "六级")
                {
                    f=0.15;
                }
                else if (s == "七级")
                {
                    f=0.1;
                }

                string s2 = ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("三度烧烫伤与给付比例").ToString().Trim();

                double f2=0;

                if (s == string.Empty)
                {
                    f2 = 0;
                }
                else if (s == "头手部8%")
                {
                    f2 = 1;
                }
                else if (s == "头手部不少于5%")
                {
                    f2 = 0.75;
                }
                else if (s == "头手部不少于2%")
                {
                    f2 = 0.5;
                }
                else if (s == "身体其它不少于20%")
                {
                    f2 = 1;
                }
                else if (s == "身体其它不少于15%")
                {
                    f2 = 0.75;
                }
                else if (s == "身体其它不少于10%")
                {
                    f2 = 0.5;
                }

                double t = f + f2 > 1 ? 1 : f + f2;

                double k1=ppa.Amount*t;
                double k2=ppa.Amount -ppa.GetDutyTotalValue("意外伤残保险金");

                da.Value = k1 > k2 ? k2 : k1;

            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("公共交通意外身故"))
            {
                ppa.SchemePeriodActing.InsurantStates.Add("意外身故");

                da.Value = ppa.Amount;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("公共交通意外伤残"))
            {
                ppa.SchemePeriodActing.AddInsurantStates("意外伤残");

                IDutyActing da2 = ppa.DutyActings.FirstOrDefault(p => p.Duty.Name == "意外伤残保险金");

                if (da2 != null)
                {
                    da.Value = da2.Value;
                }

            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("自驾车意外身故"))
            {
                ppa.SchemePeriodActing.AddInsurantStates("意外身故");

                da.Value = ppa.Amount;

                ppa.IsCurrentFinish = true;

            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("自驾车意外伤残"))
            {
                ppa.SchemePeriodActing.AddInsurantStates("意外伤残");

                IDutyActing da2 = ppa.DutyActings.FirstOrDefault(p => p.Duty.Name == "意外伤残保险金");

                if (da2 != null)
                {
                    da.Value = da2.Value;
                }

            }
        }
    }
}
